An Opus v4 SwapWin replacement

back to section start!

  Here are two different versions of the 'SwapWin' function, that was
available in Opus v4, presented below.  Each one uses a different approach
to do the same thing.

  Leo's, the top one, simply gets the path from each lister and tells the
other lister to read it in.  This retains the current lister format, unless
the paths read have specific formats.

  Edmund takes the approach of just getting each listers position and then
sending that position to the other lister, so the listers effectively swap
positions on the screen.  The only thing is that if your destination lister
was setup to show filetype in the format and the source wasn't, when you
swap positions the opposite will now be true.

  With Leo's script he asks for the handle of the SOURCE and
DESTINATION lister, if either one of those don't exist then the script
will exit, giving you an error message.

  Edmund's, on the other hand, asks for the handles of all listers
currently open, if there is less than two the script will end.  It then checks
to see if there are both a SOURCE and DESTINATION lister, if either or
both are not available, then the first two from the list of handles we asked
for are used as the SOURCE and DESTINATION respectively.  So the only
reason it should exit is because you have less than two listers open.

---------------------------------------8<---------------------------------------
/* WinSwap for Directory Opus 5.
   by Leo 'Nudel' Davidson for Gods'Gift Utilities
   email: leo.davidson@keble.oxford.ac.uk
   www: http://users.ox.ac.uk/~kebl0364
$VER: WinSwap.dopus5 1.4 (26.12.95)

   NOTE: This script _requires_ DOpus v5.11 or above.
   NOTE: DOpusFuncs is an assembler version of this (and other) scripts.

   This script will swap around your source and destination listers,
   like the old swap command in DOpus4.

   Obviously, in DOpus5 it is possible to simply move the two lister
   windows, but somethimes this isn't desireable. For example, when they
   are locked in place via the option in the pull-off menu; when you're
   too lazy to move the windows; or when the two windows are positioned
   such that moving them would be difficult or would make a mess.

Call as:
------------------------------------------------------------------------------
ARexx DOpus5:ARexx/WinSwap.dopus5 {Qp}
------------------------------------------------------------------------------
Turn off all switches.
*/

options results
options failat 99
signal on syntax;signal on ioerr                /* Error trapping */
parse arg DOpusPort
DOpusPort = Strip(DOpusPort,"B",'" ')

If DOpusPort="" THEN Do
        Say "Not correctly called from Directory Opus 5!"
        Say "Load this ARexx script into an editor for more info."
        EXIT
        END
If ~Show("P",DOpusPort) Then Do
        Say DOpusPort "is not a valid port."
        EXIT
        End
Address value DOpusPort

lister query source stem source_handle.

IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
        dopus request '"You must have a SOURCE lister!" OK'
        EXIT
        End


lister query dest stem dest_handle.

IF dest_handle.count = 0 | dest_handle.count = "DEST_HANDLE.COUNT" Then Do
        dopus request '"You must have a DESTINATION lister!" OK'
        EXIT
        End

lister query source_handle.0 path
source_path = RESULT
lister query dest_handle.0 path
dest_path = RESULT

lister read source_handle.0 '"'||dest_path||'"'
lister read dest_handle.0 '"'||source_path||'"'

syntax:;ioerr:                          /* In case of error, jump here */
EXIT

---------------------------------------8<---------------------------------------

/*
  $VER: SwapListers.dopus5 1.0 (30.1.96)
  Written by Edmund Vermeulen (edmundv@grafix.xs4all.nl).

  ARexx script for Directory Opus 5 to swap the source and destination
  listers around. If there is no source and/or destination lister it will
  take the next other lister.

  It takes a different (better :-) approach then Leo's WinSwap script. It
  simply swaps the lister positions around, instead of the directory paths.

  Function : ARexx      DOpus5:ARexx/SwapListers.dopus5 {Qp}
*/

parse arg portname .
if portname = '' then  /* in case they forgot */
  portname = 'DOPUS.1'

address value portname
options results

lister query all stem handle.
if rc > 0 | handle.count < 2 then
  exit

lister query source
if rc = 0 then do
  parse var result srchandle .
  do i = 0 to handle.count - 1
    if handle.i = srchandle then do
      handle.i = handle.0
      handle.0 = srchandle  /* make 0 the source handle */
      leave
      end
    end
  end

lister query dest
if rc = 0 then do
   parse var result desthandle .
   if handle.0 = desthandle then
      handle.0 = handle.1
   handle.1 = desthandle  /* make 1 the destination handle */
   end

do i = 0 to 1
  lister query handle.i position
  pos.i = result
  end

lister set handle.0 position pos.1
lister set handle.1 position pos.0
exit

---------------------------------------8<---------------------------------------

DOpus PLUS - giving you that bit extra...